package hight;

import java.util.concurrent.locks.LockSupport;

/**
 * park（blocker） 可传入阻塞着对象，一般出入this，可以在线程堆站中看到
 */
public class LockSupportTest2 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            System.out.println(Thread.currentThread().isInterrupted() + " start run");
            // 调用线程的interrupt也会导致park被终端，当发生终端时执行自定义操作
            LockSupport.park();

            System.out.println(Thread.currentThread().getName() + " stop run");

        });
        t.start();
        try {
            t.join();
            System.out.println(Thread.currentThread().getName()+" stop run");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
